Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build prompt when necessary #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Angelin01
Copy link

@Angelin01 Angelin01 commented Aug 13, 2024

This PR aims to HEAVILY improve performance by running the "build" portion of the prompt only when necessary.

Before, the script checked for colors, shell, and many commands on every prompt. Now, we build the prompt only after it is updated.

Now, a few things about this PR:

  1. I have NOT tested for ZSH, at all. I don't use ZSH, so I wouldn't even know how to validate it.
  2. I did test for bash as much as I could, and I noticed no problems, but I'm sure there's some stupid edge cases I haven't accounted for.

Overall, I didn't find a way to "benchmark" this. I had been running a personal, heavily modified version of this script, which only accounts for Bash, Linux, tput being available, etc, and while doing that and building the prompt, I get a 15x (yes 1500%) speed improvement, which I benchmarked like this: time { for i in {1..1000}; do kube_ps1 > /dev/null; done }.

However, this doesn't work for this script since we do it "lazily". I'd appreciate any way to benchmark this. I'd also appreciate some validation on ZSH before I mark this PR ready to review.

@Angelin01 Angelin01 marked this pull request as ready for review August 14, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant